package com.wanlong.rpc.service.impl;

import com.github.pagehelper.PageInfo;
import com.wanlong.rpc.service.SysMemberManagerService;
import com.wanlong.sys.model.SysPrivilege;
import com.wanlong.sys.model.SysRole;
import com.wanlong.sys.model.SysUser;
import com.wanlong.sys.service.ISysPrivilegeService;
import com.wanlong.sys.service.ISysRoleService;
import com.wanlong.sys.service.ISysUserRoleService;
import com.wanlong.sys.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 万龙
 * @name
 * @project_name wanlong
 * @package_name com.wanlong.rpc.service.impl
 * @description
 * @date 2019/2/9
 */
@Service("sysMemberManagerService")
public class SysMemberManagerServiceImpl implements SysMemberManagerService {
    @Autowired
    private ISysUserService sysUserService;

    @Autowired
    private ISysRoleService sysRoleService;

    @Autowired
    private ISysUserRoleService sysUserRoleService;

    @Autowired
    private ISysPrivilegeService sysPrivilegeService;


    @Override
    public long insertSysUser(SysUser sysUser) {
        return sysUserService.insert(sysUser);
    }

    @Override
    public int updateSysUser(SysUser sysUser) {
        return sysUserService.update(sysUser);
    }

    @Override
    public int deleteSysUser(SysUser sysUser) {
        return sysUserService.delete(sysUser);
    }

    @Override
    public SysUser getSysUserById(Long id) {
        return sysUserService.getSysUserById(id);
    }

    @Override
    public SysUser getSysUserByLoginName(String loginName) {
        SysUser sysUser = sysUserService.getSysUserListByName(loginName);
        return sysUser;
    }

    @Override
    public PageInfo<SysUser> getPageSysUserListByName(String loginName, Integer pageNo, Integer pageSize) {
        PageInfo<SysUser> sysUserList = sysUserService.getPageSysUserListByName(loginName,pageNo,pageSize);
        return sysUserList;
    }

    @Override
    public long insertSysRole(SysRole sysRole) {
        return sysRoleService.insert(sysRole);
    }

    @Override
    public int updateSysRole(SysRole sysRole) {
        return sysRoleService.update(sysRole);
    }

    @Override
    public int deleteSysRole(SysRole sysRole) {
        return sysRoleService.delete(sysRole);
    }

    @Override
    public PageInfo<SysRole> getPageSysRoleListByName(String name, Integer pageNo, Integer pageSize) {
        PageInfo<SysRole> sysRoleList = sysRoleService.getPageSysRoleListByName(name,pageNo,pageSize);
        return sysRoleList;
    }

    @Override
    public List<SysRole> getAllSysRoleList() {
        List<SysRole> sysRoleList = sysRoleService.getAllSysRoleList();
        return sysRoleList;
    }

    @Override
    public Long[] getRolesByUser(long userId) {
        Long[] roles = sysUserRoleService.getRolesByUser(userId);
        return roles;
    }

    @Override
    public long insertSysPrivilege(SysPrivilege sysPrivilege) {
        return sysPrivilegeService.insert(sysPrivilege);
    }

    @Override
    public int updateSysPrivilege(SysPrivilege sysPrivilege) {
        return sysPrivilegeService.update(sysPrivilege);
    }

    @Override
    public int deleteSysPrivilege(SysPrivilege sysPrivilege) {
        return sysPrivilegeService.delete(sysPrivilege);
    }

    @Override
    public PageInfo<SysPrivilege> getPageSysPrivilegeListByName(String name, Integer pageNo, Integer pageSize) {
        PageInfo<SysPrivilege> sysPrivilegeList = sysPrivilegeService.getPageSysPrivilegeListByName(name,pageNo,pageSize);
        return sysPrivilegeList;
    }
}
